﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using LogManager.Base.Data;

namespace LogManager.Base
{
    /// <summary>
    /// A log where records are saved
    /// </summary>
    /// <remarks>
    /// There are no undefined types in a log.
    /// </remarks>
    public abstract class BaseLog : ILog
    {
        public virtual void Initialize(string serverName, string logName, string typeId)
        {
            ServerName = serverName;
            LogName = logName;
            Type = typeId;
        }

        #region ILog Members

        [DisplayName("Log")]
        public string LogName { get; set; }       
        [DisplayName("Server")]
        public string ServerName { get; set; }
        public string Type { get; private set; }

        public DateTime? LastWriteTime
        {
            get { return (DateTime?)Properties.GetValueOrDefault("LastWriteTime",null); }
            set { Properties["LastWriteTime"] = value; }
        }

        public int? Count
        {
            get { return (int?)Properties.GetValueOrDefault("Count", null); }
            set { Properties["Count"] = value; }
        }

        public abstract IDictionary<string, object> Properties { get; }

        public virtual IEventExportService ExportService
        {
            get;
            protected set;
        }

        #endregion          
    }
}
